<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="demo">
			
		</div>
		<script>
		function myDisplayer(some) {
		  document.getElementById("demo").innerHTML = some;
		}
		
		let myPromise = new Promise(function(myResolve, myReject) {
		  let x = Math.random();
		
		// 生成代码（这可能需要一些时间）
		
		  if (x >0.5) {
		    myResolve("OK");
		  } else {
		    myReject("Error");
		  }
		});
		
		myPromise.then(
		  function(value) {myDisplayer(value);},
		  function(error) {myDisplayer(error);}
		);
		</script>
	</body>
</html>
